/**
 * AirFlightCode.java
 * 2010-1-23
 */
package com.dlplay.flightinfo.data;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
/**
 * @author zhao yu
 * represent the air flight number, such as CA1686
 * http://www.222666.cn/know_06.html
 */
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class AirFlightCode {
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Long id;
    
    @Persistent
	private AirlineCode code; //CA, MU
    @Persistent
	private int number;//4 number is for domestic, 3 number is for international
	/**
	 * @return the code
	 */
	public final AirlineCode getCode() {
		return code;
	}
	/**
	 * @param code the code to set
	 */
	public final void setCode(AirlineCode code) {
		this.code = code;
	}
	/**
	 * @return the number
	 */
	public final int getNumber() {
		return number;
	}
	/**
	 * @param number the number to set
	 */
	public final void setNumber(int number) {
		this.number = number;
	}
	
	/**
	 * @param code
	 * @param number
	 */
	public AirFlightCode(AirlineCode code, int number) {
		super();
		this.code = code;
		this.number = number;
	}
	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		AirFlightCode other = (AirFlightCode) obj;
		if (code == null) {
			if (other.code != null)
				return false;
		} else if (!code.equals(other.code))
			return false;
		if (number != other.number)
			return false;
		return true;
	}
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return ""+code+ number;
	}
}
